package cn.worken.baseframe.facade.bo;

import cn.worken.baseframe.service.domain.DemoDO;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author genxin.liu
 * @since 2021/12/27 14:27
 */
@Data
public class DemoBO {
    
    private Long id;
    private String name;
    
    public static DemoBO copy(DemoDO bean) {
        DemoBO data = new DemoBO();
        data.setId(bean.getId());
        data.setName(bean.getName());
        return data;
    }
    
    public static List<DemoBO> copyList(List<DemoDO> beans) {
        if (CollectionUtils.isEmpty(beans)) {
            return Collections.EMPTY_LIST;
        }
        return beans.stream().map(DemoBO::copy).collect(Collectors.toList());
    }
}
